<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/lib/bootstrap/css//bootstrap.min.css"/>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/lib/bootstrap/css/bootstrap-theme.min.css"/>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/entry-apply.css"/>
<div class="xiu-container">
    <div class="apply-wrap" id="j-yr-apply">
        <h1 class="app-tit">艺人申请入驻</h1>
        <!--进度步骤导航-->
        <div class="apply-step clearfix">
            <ul class="progress-step-nav">
                <li class="active"><a href="javascript:;"><i>1</i>个人资料</a></li>
                <li><a href="javascript:;"><i>2</i>财务信息</a></li>
                <li><a href="javascript:;"><i>3</i>封面照片</a></li>
                <li><a href="javascript:;"><i>4</i>完成</a></li>
            </ul>
        </div>

        <!-- 进度步骤-->
        <div class="progress-step-cont">
            <div class="step-cont-outer">
                <div class="step-cont-inner">
                    <div class="step-cont-mod step-1">
                        <form class="form-horizontal">
                            <div class="form-group">
                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">申请入驻账号</label>
                                    <div class="col-sm-10" id="J_NickName_Info">
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">真实姓名</label>
                                    <div class="col-sm-5" id="J_RealName_Info">
                                    </div>
                                    <div class="col-sm-5">
                                        <p>（请填写您本人真实姓名，同时真实姓名与身份证及银行卡户名请保持一致）</p>
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">性别</label>
                                    <div class="col-sm-2">
                                        <select class="form-control" name="sex" id="J_Sex_Info">
                                        </select>
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">手机号码</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" placeholder="请输入您的手机号码~" name="mobile"  id="apply_mobile" value="">
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">QQ</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" placeholder="请输入您的QQ~" name="qq">
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">邮箱</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" placeholder="请输入您的邮箱~" name="email" id="apply_email" value="">
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">直播类型</label>
                                    <div class="col-sm-2">
                                        <select class="form-control" name="lablename" id="J_Tage_Info">
                                        </select>
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">常用线路</label>
                                    <div class="col-sm-2">
                                        <select class="form-control" name="common_line">
                                            <option value="1">电信</option>
                                            <option value="2">联通</option>
                                            <option value="3">移动</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                <label for="" class="col-sm-2 control-label">公会ID</label>
                                <div class="col-sm-2">
                                <input type="text" class="form-control" placeholder="公会ID"  name="familyId" id="J_FamilyID_Js" >
                                </div>
                                    <div class="col-sm-5">

                                        <p><span id="J_Family_Name" style="color:red"></span>（注释：该项是属于选填项，该项是填写公会的ID申请公会艺人,不填写公会ID为平台艺人）</p>
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button class="btn btn-primary" type="button" id="step-s1">下一步</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        ////////////////////////////////////
        //判断是否登录或者是否申请艺人或公会
        ////////////////////////////////////
        if(_StateData.IsAnchor){
            $.CommonMain.Modal_Tip('你已经申请了艺人，无需申请了', {
                Timeout: 1000,
                onClose: function () {
                    location.href = "/";
                }
            });
        }
        if(_PageData.flag==2){
            $.CommonMain.Modal_Tip(_PageData.message, {
                Timeout: 2000,
                onClose: function () {
                    location.href = "/";
                }
            });
        }
        ////////////////////////////////////
        //判断PageData
        ////////////////////////////////////
        if (!$.CommonMain.PageDataCheck()) {
            return;
        }
        $("#J_FamilyID_Js").keyup(function(){
            var params = {};
            params.Family_ID = $.trim($('input[name="familyId"]').val());//公会Id
            if(params.familyId !=''){
                $.KOC.Loading.Open();
                $.ajax({
                    url: '/ajax/business.family-info',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        Family_ID:params.Family_ID
                    },
                    success: function (data) {
                        $.KOC.Loading.Close();
                        if (data.flag !== 0) {
                            $.CommonMain.Modal_Tip(data.msg , {Timeout:1000});
                            $('#J_Family_Name').html('');
                            return;
                        }
                        $.CommonMain.Modal_Tip('验证成功' , {Timeout:1000});
                        $('#J_Family_Name').html('公会名称：'+data.Family_Name);
                    }
                });
            }else{
                $("#J_FamilyID_Js").val('');
                $('#J_Family_Name').html('');
                return true;
            }
        })
        ////////////////////////////////////
        //赋值
        ////////////////////////////////////
        var SexInfo = '';
        var TageInfo = '';
        //真实姓名
        if (_StateData.RealName) {
            $('#J_RealName_Info').empty().append(' <input type="text" class="form-control" placeholder="您的真实姓名" name="real_name" value="' + _StateData.RealName + '">');
        } else {
            $('#J_RealName_Info').empty().append(' <input type="text" class="form-control" placeholder="您的真实姓名" name="real_name" value="">');
        }
        //昵称
        if (_StateData.NickName) {
            $("#J_NickName_Info").empty().append('<p class="form-control-static">' + _StateData.NickName + '</p>');
        }
        //Sex性别
        if (_PageData.UserInfo.Sex == 1) {
            SexInfo += '<option value="1" checked="">男</option>';
            SexInfo += '<option value="2">女</option>';
        } else {
            SexInfo += '<option value="1" >男</option>';
            SexInfo += '<option value="2" checked="">女</option>';
        }
        $("#J_Sex_Info").empty().append(SexInfo);
        //艺人标签
        for (var n = 0; n < _PageData.Tags.Data.length; n++) {
            if (n == 0) {
                TageInfo += '<option value="' + _PageData.Tags.Data[n] + '" checked="">' + _PageData.Tags.Data[n] + '</option>';
            } else {
                TageInfo += '<option value="' + _PageData.Tags.Data[n] + '">' + _PageData.Tags.Data[n] + '</option>';
            }
        }
        $("#J_Tage_Info").empty().append(TageInfo);
        //手机号
        if (_PageData.UserInfo.Phone) {
            $("#apply_mobile").attr('value',_PageData.UserInfo.Phone);
        }
        //email
        if (_PageData.UserInfo.Email) {
            $("#apply_email").attr('value', _PageData.UserInfo.Email);
        }
        $('#step-s1').click(function () {
            var params = {};
            var tel = /^0?(13[0-9]|15[012356789]|18[0123456789]|17[0123456789]|14[57])[0-9]{8}$|^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9]+\.[a-zA-Z0-9\.]+$/;
            var email = /^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9]+\.[a-zA-Z0-9\.]+$/;
            params.real_name = $.trim($('input[name="real_name"]').val());//真实姓名
            params.mobiles = $.trim($('input[name="mobile"]').val());//手机号lableid
            params.qq = $.trim($('input[name="qq"]').val());//qq号
            params.email = $.trim($('#apply_email').val());//email
            params.sex = $.trim($('select[name="sex"]').val());//性别
            params.lablename = $.trim($('select[name="lablename"]').val());//直播类型
            params.common_line = $.trim($('select[name="common_line"]').val());//网络类型
            params.Family_ID = $.trim($('input[name="familyId"]').val());//公会ID
            if (!params.real_name) {
                $.CommonMain.Modal_Tip('请输入真实姓名', {Timeout: 1000});
                $('input[name="real_name"]').focus();
                return false;
            }

            if (!params.mobiles) {
                $.CommonMain.Modal_Tip('请输入手机号', {Timeout: 1000});
                $('#apply_mobile').focus();
                return false;
            } else if (!tel.test(params.mobiles)) {
                $.CommonMain.Modal_Tip('你输入的手机号格式不正确', {Timeout: 1000});
                $('#apply_mobile').focus();
                return false;
            }
            if (!params.qq) {
                $.CommonMain.Modal_Tip('请输入qq', {Timeout: 1000});
                $('input[name="qq"]').focus();
                return false;
            }
            if (!params.email) {
                $.CommonMain.Modal_Tip('请输入email邮箱', {Timeout: 1000});
                $('input[name="emails"]').focus();
                return false;
            }
            if (!email.test(params.email)) {
                $.CommonMain.Modal_Tip('您输入的email格式不正确,请重新输入', {Timeout: 1000});
                $('input[name="emails"]').focus();
                return false;
            }
            $.KOC.Loading.Open();
            $.ajax({
                url: '/ajax/business.user-anchorapply.stepone',
                type: 'post',
                dataType: 'json',
                data: {
                    RealName: params.real_name,
                    Phone: params.mobiles,
                    QQ: params.qq,
                    Email: params.email,
                    Tags: params.lablename,
                    Network: params.common_line,
                    Family_ID:params.Family_ID,
                    Sex: params.sex
                },
                success: function (data) {
                    $.KOC.Loading.Close();
                    if (data.flag !== 0) {
                        $.CommonMain.Modal_Tip(data.msg + "(" + data.flag + ")", {Timeout: 2000});
                        return;
                    }

                    var url = "/entry/anchor/step_2";
                    location.href = url;
                }
            });

        });
    });
</script>